package com.shujia.exception_;

import org.junit.Test;

import java.util.Scanner;

public class ExceptionDemo {

    //OOM
    @Test
    public void test3() {
        StringBuffer sb = new StringBuffer();
        while (true) {
            sb.append("OOM");
        }

    }

    // StackOverflowError
    @Test
    public void test1() {
        method();
    }

    public void method() {
        int i = 10;
        method();
    }


    public static void main(String[] args) {
        System.out.println(Integer.MAX_VALUE);

        Scanner sc = new Scanner(System.in);
        String str = sc.next();

        boolean flag = str.matches("\\d+");
        if (!flag) {
            System.out.println("输入的数字不合法!");
            return;
        }

        // 在Integer 范围内逻辑很难实现
        // if()

        Integer num = Integer.valueOf(str);
        System.out.println(num);
    }
}
